﻿using System;
using USNetFramework.Network;

namespace USNetFramework.RPC
{
    public delegate void RpcEvent(NetPacket retPacket);
    public class RpcObject
    {
        event RpcEvent rpcEvent;
        DateTimeOffset rpcTime;
        public RpcEvent RpcEvent { get => rpcEvent; set => rpcEvent = value; }
        public DateTimeOffset RpcTime { get => rpcTime;}

        public RpcObject(RpcEvent _rpcEvent)
        {
            rpcEvent = _rpcEvent;
            rpcTime = DateTimeOffset.UtcNow;
        }

        public virtual void Dispatch(NetPacket _packet)
        {
            if (null == rpcEvent)
                return;
            rpcEvent(_packet);
        }
    }
}

